# RT-Thread building script for component
Import('rtconfig')
from building import *

cwd = GetCurrentDir()
libs = []
src = Glob('*src/*.c') + Glob('src/*.cpp')
cpppath = [cwd + '/inc']
libpath = [cwd + '/lib']


if not GetDepend('BSP_USE_STDDRIVER_SOURCE'):
    if rtconfig.CROSS_TOOL == 'keil':
        if GetOption('target') == 'mdk5' and os.path.isfile('./lib/libstddriver_keil.lib'):
            libs += ['libstddriver_keil']
    elif rtconfig.CROSS_TOOL == 'gcc' and os.path.isfile('./lib/libstddriver_gcc_CM4.a') and GetDepend('USE_MA35D1_SUBM'):
        libs += ['libstddriver_gcc_CM4']
    elif rtconfig.CROSS_TOOL == 'gcc' and os.path.isfile('./lib/libstddriver_gcc_CA35.a') and GetDepend('USE_MA35D1_AARCH32'):
        libs += ['libstddriver_gcc_CA35']

if not libs:
    group = DefineGroup('Libraries', src, depend = [''], CPPPATH = cpppath)
else:
    src = []
    group = DefineGroup('Libraries', src, depend = [''], CPPPATH = cpppath, LIBS = libs, LIBPATH = libpath)

Return('group')
